import { IConfig } from '../../react/features/base/config/configType';

import type { Participant } from './Participant';
import { ITestProperties } from './TestProperties';
import type WebhookProxy from './WebhookProxy';
import { IToken, ITokenOptions } from './token';

export type IContext = {
    /**
     *  The up-to-four browser instances provided by the framework. These can be initialized using
     *  ensureOneParticipant, ensureTwoParticipants, etc. from participants.ts.
     **/
    p1: Participant;
    p2: Participant;
    p3: Participant;
    p4: Participant;
    /** A room name automatically generated by the framework for convenience. */
    roomName: string;
    /**
     * A flag that tests can set, which signals to the framework that the (rest of the) test suite should be skipped.
     * A string value indicates the reason for the skipped (to be included in the Allure report).
     */
    skipSuiteTests: boolean | string;
    /**
     * Test properties provided by the test file via TestProperties.setTestProperties. Used by the framework to
     * set up the context appropriately.
     **/
    testProperties: ITestProperties;
    times: any;
    /**
     * A WebhooksProxy instance generated by the framework and available for tests to use, if configured.
     * Note that this is only configured for roomName, if a test wishes to use a different room name it can set up
     * a WebhooksProxy instance itself.
     */
    webhooksProxy: WebhookProxy;
};

export type IParticipantOptions = {
    /** Whether it should use the iFrame API. */
    iFrameApi?: boolean;
    /** Determines the browser instance to use. */
    name: 'p1' | 'p2' | 'p3' | 'p4';
    /** An optional token to use. */
    token?: IToken;
};

/**
 * Options for joinConference.
 */
export type IParticipantJoinOptions = {

    /**
     * Config overwrites to use.
     */
    configOverwrite?: IConfig;

    /** The name of the room to join */
    roomName: string;

    /**
     * Whether to skip setting display name.
     */
    skipDisplayName?: boolean;

    /**
     * Whether to skip waiting for the participant to join the room. Cases like lobby where we do not succeed to join
     * based on the logic of the test.
     */
    skipWaitToJoin?: boolean;

    /**
     * An optional tenant to use. If provided it overrides the default.
     */
    tenant?: string;
};

export type IJoinOptions = {

    /**
     * Config overwrites to pass to IParticipantJoinOptions.
     */
    configOverwrite?: IConfig;

    /**
     * To be able to override the ctx generated room name. If missing the one from the context will be used.
     */
    roomName?: string;

    /**
     *The skip display name setting to pass to IParticipantJoinOptions.
     */
    skipDisplayName?: boolean;

    /**
     * Whether to skip in meeting checks like ice connected and send receive data. For single in meeting participant.
     */
    skipInMeetingChecks?: boolean;

    /**
     * The skip waiting for the participant to join the room setting to pass to IParticipantJoinOptions.
     */
    skipWaitToJoin?: boolean;

    /**
     * An optional tenant to use. If provided the default tenant is changed to it.
     */
    tenant?: string;

    /**
     * Options used when generating a token.
     */
    tokenOptions?: ITokenOptions;
};
